package com.hutao.manage.controller;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.hutao.manage.constant.Constant;
import com.hutao.manage.enums.ExportDataEnum;
import com.hutao.manage.query.ExportCSVParam;
import com.hutao.manage.service.ExportCSVService;
import com.hutao.manage.service.impl.ExportCSVServiceImpl;
import com.hutao.manage.util.CSVUtil;
import com.hutao.manage.util.DateSplitUtil;
import com.hutao.manage.util.ListSplitUtil;
import com.hutao.manage.util.ReadExcelUtil;
import com.hutao.manage.util.Result;

@Controller
@RequestMapping("/csv")
public class ExportCSVController {

	private Logger logger = LoggerFactory.getLogger(ExportCSVServiceImpl.class);

	@Autowired
	private ExportCSVService exportCSVService;
	
	private static String exportFileName;

	private static List<Map<String, Object>> adrInfoRecordList = new ArrayList<>();

	@ResponseBody
	@RequestMapping("/exportPatientinfo")
	public void exportPatientinfo(ExportCSVParam exportCSVParam, HttpServletResponse response,
			HttpServletRequest request) {
		// 解决跨域问题
		response.setHeader("Access-Control-Allow-Origin", "*");
		try {
			// 患者基本信息表 (patient_info)
			Integer dataType = exportCSVParam.getDataType();
			if (dataType.intValue() == ExportDataEnum.PATIENT_INFO.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.PATIENT_INFO_HEADER,
						ExportDataEnum.PATIENT_INFO.getName().toString());
				// 患者药物不良反应(adr_info)
			} else if (dataType.intValue() == ExportDataEnum.ADR_INFO.getValue().intValue()) {
				exportAdrRecordBatch(response, exportCSVParam, Constant.ADR_INFO_HEADER,
						ExportDataEnum.ADR_INFO.getName().toString());
				// 病案首页
			} else if (dataType.intValue() == ExportDataEnum.MEDICAL_RECORD_HOMEPAGE.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.MEDICAL_RECORD_HOMEPAGE_HEADER,
						ExportDataEnum.MEDICAL_RECORD_HOMEPAGE.getName().toString());
				// 入院记录
			} else if (dataType.intValue() == ExportDataEnum.EMR_ADMISSION.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.EMR_ADMISSION_HEADER,
						ExportDataEnum.EMR_ADMISSION.getName().toString());
				// 病程记录
			} else if (dataType.intValue() == ExportDataEnum.EMR_PROCESS.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.EMR_PROCESS_HEADER,
						ExportDataEnum.EMR_PROCESS.getName().toString());
				// 出院记录
			} else if (dataType.intValue() == ExportDataEnum.EMR_DISCHARGE.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.EMR_DISCHARGE_HEADER,
						ExportDataEnum.EMR_DISCHARGE.getName());
				// 住院手术记录
			} else if (dataType.intValue() == ExportDataEnum.INPATIENT_SURGICAL_RECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.INPATIENT_SURGICAL_RECORD_HEADER,
						ExportDataEnum.INPATIENT_SURGICAL_RECORD.getName());
				// 住院护理记录
			} else if (dataType.intValue() == ExportDataEnum.INPATIENT_NURSING_RECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.INPATIENT_NURSING_RECORD_HEADER,
						ExportDataEnum.INPATIENT_NURSING_RECORD.getName());
				// 住院医嘱
			} else if (dataType.intValue() == ExportDataEnum.INPATIENT_ORDER.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.INPATIENT_ORDER_HEADER,
						ExportDataEnum.INPATIENT_ORDER.getName());
				// 住院收费记录
			} else if (dataType.intValue() == ExportDataEnum.INPATIENT_EXPENSE_RECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.INPATIENT_EXPENSE_RECORD_HEADER,
						ExportDataEnum.INPATIENT_EXPENSE_RECORD.getName());
				// 门诊信息记录
			} else if (dataType.intValue() == ExportDataEnum.OUTPATIENT_INFO.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.OUTPATIENT_INFO_HEADER,
						ExportDataEnum.OUTPATIENT_INFO.getName());
				// 门诊诊断及病历记录
			} else if (dataType.intValue() == ExportDataEnum.OUTPATIENT_DIAG_MEDRECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.OUTPATIENT_DIAG_MEDRECORD_HEADER,
						ExportDataEnum.OUTPATIENT_DIAG_MEDRECORD.getName());
				// 门诊医嘱及处方
			} else if (dataType.intValue() == ExportDataEnum.OUTPATIENT_ORDER_AND_PRES.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.OUTPATIENT_ORDER_AND_PRES_HEADER,
						ExportDataEnum.OUTPATIENT_ORDER_AND_PRES.getName());
				// 门诊费用信息
			} else if (dataType.intValue() == ExportDataEnum.OUTPATIENT_EXPENSE_RECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.OUTPATIENT_EXPENSE_RECORD_HEADER,
						ExportDataEnum.OUTPATIENT_EXPENSE_RECORD.getName());
				// 临床检查记录
			} else if (dataType.intValue() == ExportDataEnum.EXAM_INFO.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.EXAM_INFO_HEADER,
						ExportDataEnum.EXAM_INFO.getName());
				// 实验室检查信息
			} else if (dataType.intValue() == ExportDataEnum.LAB_INFO.getValue().intValue()) {
				// exportTurnBatch(response, exportCSVParam, Constant.LAB_INFO_HEADER,
				// ExportDataEnum.LAB_INFO.getName());
				exportLabBatch(response, exportCSVParam, Constant.LAB_INFO_HEADER, ExportDataEnum.LAB_INFO.getName());
				// 病理检查信息
			} else if (dataType.intValue() == ExportDataEnum.PATHLOGICAL_EXAM_RECORD.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.PATHLOGICAL_EXAM_RECORD_HEADER,
						ExportDataEnum.PATHLOGICAL_EXAM_RECORD.getName());
				// 抗肿瘤药物采购清单
			} else if (dataType.intValue() == ExportDataEnum.DRUG_PURCHASE.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.DRUG_PURCHASE_HEADER,
						ExportDataEnum.DRUG_PURCHASE.getName());
				// 抗肿瘤药物使用清单
			} else if (dataType.intValue() == ExportDataEnum.DRUG_USER.getValue().intValue()) {
				exportDrugUseBatch(response, exportCSVParam, Constant.DRUG_USE_HEADER,
						ExportDataEnum.DRUG_USER.getName());
				//患者诊断记录
			}else if (dataType.intValue() == ExportDataEnum.DIAG_INFO.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.DIAG_INFO_HEADER,
						ExportDataEnum.DIAG_INFO.getName());
				//住院患者信息表（ inpatient_info）
			}else if (dataType.intValue() == ExportDataEnum.INPATIENT_INFO.getValue().intValue()) {
				exportTurnBatch(response, exportCSVParam, Constant.INPATIENT_INFO_HEADER,
						ExportDataEnum.INPATIENT_INFO.getName());
			}


		} catch (Exception e) {
			e.printStackTrace();

		}

	}

	/**
	 * 导出报表
	 * 
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	private void exportDrugUseBatch(HttpServletResponse response, ExportCSVParam exportCSVParam, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((fileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());

			// 分页查询数据
			List<Map<String, Object>> resultList = exportCSVService.getExportDrugUseDataInfo(exportCSVParam);

			int dataLength = resultList.size();
			for (int i = 0; i < dataLength; i++) {
				// 解决乱码
				out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
				out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
			}
			out.flush();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

	/**
	 * 导出报表
	 * 
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	@SuppressWarnings("unused")
	private void exportBatch(HttpServletResponse response, ExportCSVParam exportCSVParam, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((fileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());
			int pageNumber = Constant.PAGE_NO;
			int pageSize = Constant.PAGE_SIZE;
			int dataLength = pageSize;
			while (dataLength == pageSize) {
				int startIndex = (pageNumber - 1) * pageSize;
				exportCSVParam.setStartIndex(startIndex);
				exportCSVParam.setPageSize(startIndex + pageSize);
				// 分页查询数据
				List<Map<String, Object>> resultList = exportCSVService.getExportDataInfo(exportCSVParam);

				dataLength = resultList.size();
				for (int i = 0; i < dataLength; i++) {
					// 解决乱码
					out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
					out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
				}
				out.flush();
				pageNumber++;
			}
		} catch (IOException e) {
			e.printStackTrace();
			logger.error("导出" + fileName + "发生错误:", e);
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

	/**
	 * 分批导入数据
	 * 
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	private void exportTurnBatch(HttpServletResponse response, ExportCSVParam exportCSVParam, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((fileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());
			out.flush();

			writeDataForCvs(out, exportCSVParam, header);

		} catch (IOException e) {
			e.printStackTrace();
			logger.error("导出" + fileName + "发生错误:", e);
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}
	
	
	/**
	 * 分批导入数据
	 * 
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	private void exportAdrRecordBatch(HttpServletResponse response, ExportCSVParam exportCSVParam, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((exportFileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());
			
			
			List<Map<String, Object>> resultList = adrInfoRecordList;
			int dataLength = resultList.size();
			
			for (int i = 0; i < dataLength; i++) {
				// 解决乱码
				out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
				out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
			}
			out.flush();

		} catch (IOException e) {
			e.printStackTrace();
			logger.error("导出" + fileName + "发生错误:", e);
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

	

	/**
	 * 分批导入数据
	 * 
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	private void exportLabBatch(HttpServletResponse response, ExportCSVParam exportCSVParam, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((fileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());
			out.flush();

			writeLabDataForCvs(out, exportCSVParam, header);

		} catch (IOException e) {
			e.printStackTrace();
			logger.error("导出" + fileName + "发生错误:", e);
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

	/**
	 * 分批次带出门诊实验室检测信息
	 * 
	 * @param out
	 * @param exportCSVParam
	 * @param header
	 */
	public void writeLabDataForCvs(OutputStream out, ExportCSVParam exportCSVParam, String[] header) {

		int count = 0;

		try {
			List<String> list = DateSplitUtil.cutDate("D", exportCSVParam.getStartTime(), exportCSVParam.getEndTime());

			List<List<String>> subDateList = ListSplitUtil.split(list, 5);

			for (List<String> subDates : subDateList) {

				int subLength = subDates.size();
				String startTime = subDates.get(0) + " 00:00:00";
				String endTime = subDates.get(subLength - 1) + " 23:59:59";
				exportCSVParam.setStartTime(startTime);
				exportCSVParam.setEndTime(endTime);

				List<String> onlyIdList = exportCSVService.getMrOutLabOnlyId(exportCSVParam);

				if (CollectionUtils.isEmpty(onlyIdList)) {
					continue;
				}

				List<List<String>> onlyIdLists = ListSplitUtil.split(onlyIdList, 1000);

				for (List<String> onlyIds : onlyIdLists) {
					List<Map<String, Object>> resultList = exportCSVService.getMrOutLabRecordByOnlyIds(onlyIds);
					int dataLength = resultList.size();
					count += dataLength;
					logger.info("当前导出数据总数为:" + count + "条,此次导出数据条数为:" + dataLength + "条");
					for (int i = 0; i < dataLength; i++) {
						// 解决乱码
						out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
						out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
					}
					out.flush();
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			try {
				if (out != null)
					out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	public void writeDataForCvs(OutputStream out, ExportCSVParam exportCSVParam, String[] header) {

		try {

			List<String> list = DateSplitUtil.cutDate("D", exportCSVParam.getStartTime(), exportCSVParam.getEndTime());

			List<List<String>> subDateList = ListSplitUtil.split(list, 2);

			int count = 0;

			for (List<String> subDates : subDateList) {

				int subLength = subDates.size();
				String startTime = subDates.get(0) + " 00:00:00";
				String endTime = subDates.get(subLength - 1) + " 23:59:59";

				logger.info("当前查询参数->开始时间:" + startTime + " ,结束时间:" + endTime);

				exportCSVParam.setStartTime(startTime);
				exportCSVParam.setEndTime(endTime);
				int pageNumber = Constant.PAGE_NO;
				int pageSize = Constant.PAGE_SIZE;
				int dataLength = pageSize;
				while (dataLength == pageSize) {
					int startIndex = (pageNumber - 1) * pageSize;
					exportCSVParam.setStartIndex(startIndex);
					exportCSVParam.setPageSize(startIndex + pageSize);
					// 分页查询数据
					List<Map<String, Object>> resultList = exportCSVService.getExportDataInfo(exportCSVParam);
					dataLength = resultList.size();
					if (CollectionUtils.isNotEmpty(resultList)) {
						
						count += dataLength;
						logger.info("此次导出数据为->:" + dataLength + "条,导出数据总条数为->:" + count + "条");
						for (int i = 0; i < dataLength; i++) {
							// 解决乱码
							out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
							out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
						}
						out.flush();
					}
					pageNumber++;

				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			try {
				if (out != null)
					out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	// 处理文件上传
	@CrossOrigin
	@ResponseBody
	@RequestMapping(value = "/transferExcel", method = RequestMethod.POST)
	public Result uploadImg(@RequestParam("file") MultipartFile file, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// 解决跨域问题
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Cache-Control", "no-cache");


		if (!file.isEmpty()) {
			//
			String filename = file.getOriginalFilename();
			String prefix = filename.substring(filename.lastIndexOf(".") + 1);
			exportFileName = filename.substring(0, filename.lastIndexOf("."));
			// Excel 2007版9
			if (null != prefix && (prefix.equalsIgnoreCase("xlsx") || prefix.equalsIgnoreCase("xls"))) {
				// 返回记录数
				try {
					File f = null;
					// f = File.createTempFile("temp", prefix);
					f = new File("D://1."+prefix);
					System.out.println(f.getAbsolutePath());
					file.transferTo(f);
					f.deleteOnExit();

					List<Map<String, Object>> mapList = ReadExcelUtil.readExecl(f.getAbsolutePath());

					adrInfoRecordList = tranferAdrData(mapList);

				} catch (IOException e) {
					e.printStackTrace();
				}
				return new Result(true, "数据转换成功!");
			} else {
				return new Result(false, "请选择文件");
			}

		} else {
			return new Result(false, "文件不存在");
		}
	}

	public List<Map<String, Object>> tranferAdrData(List<Map<String, Object>> dataList) {
		List<Map<String, Object>> newMapList = new ArrayList<>();
		Map<String, Object> newMap = null;
		// {0=窦全朋, 1=男, 2=33, 3=年, 4=汉族, 5=61公斤, 6=B-细胞淋巴瘤, 7=6507731, 8=怀疑, 9=1,
		// 10=国药准字J20170034, 11=美罗华, 12=利妥昔单抗注射液,
		// 13=注射液, 14=上海罗氏制药有限公司, 15=H0268, 16=100, 17=毫克, 18=1, 19=1, 20=静脉滴注,
		// 21=2019-09-11, 22=2019-09-11, 23=靶向治疗,
		// 24=寒战（严重）；发热（严重）；肌张力过高（一般）, 25=2019-09-11 , 26=好转, 27=曲惠廷, 28=2019-09-12 }

		for (Map<String, Object> map : dataList) {
			newMap = new HashMap<>();
			// 患者ID
			newMap.put("patient_id".toUpperCase(), MapUtils.getString(map, "7"));
			// 单次就诊唯一标识号
			newMap.put("visit_sn".toUpperCase(), MapUtils.getString(map, "7"));
			// 就诊类型名称
			newMap.put("visit_type".toUpperCase(), "住院");
			// 病案号
			newMap.put("medical_record_no".toUpperCase(), MapUtils.getString(map, "7"));
			// 门诊号
			newMap.put("outpatient_no".toUpperCase(), null);
			// 姓名
			newMap.put("name".toUpperCase(), MapUtils.getString(map, "0"));
			// 药品不良反应流水号
			newMap.put("adr_event_sn".toUpperCase(), MapUtils.getString(map, "10") + MapUtils.getString(map, "15"));
			// 药品不良反应报告状态
			newMap.put("adr_report_status".toUpperCase(), null);
			// 药品不良反应报告类型
			newMap.put("adr_report_type".toUpperCase(), null);
			// 患者原患疾病
			newMap.put("adr_report_type".toUpperCase(), MapUtils.getString(map, "6"));
			// 对原患疾病的影响
			newMap.put("adr_disease_influence".toUpperCase(), null);
			// 家族药品不良反应
			newMap.put("adr_family_status".toUpperCase(), null);
			// 既往药品不良反应
			newMap.put("adr_post_status".toUpperCase(), null);
			// 其他既往信息
			newMap.put("adr_post_other".toUpperCase(), null);
			// 药品不良反应事件名称
			newMap.put("adr_event_name".toUpperCase(), MapUtils.getString(map, "24"));
			// 不良事件发生时间
			newMap.put("adr_event_time".toUpperCase(), MapUtils.getString(map, "25"));
			// 不良事件过程描述
			newMap.put("adr_event_content".toUpperCase(), MapUtils.getString(map, "26"));
			// 不良事件过程描述
			newMap.put("adr_event_content".toUpperCase(), null);
			// 不良反应结果
			newMap.put("adr_event_result".toUpperCase(), MapUtils.getString(map, "27"));
			// 停药或减药后是否减轻或消失
			newMap.put("adr_stop_status".toUpperCase(), null);
			// 再次使用药物后是否出现同样反应
			newMap.put("adr_stop_status".toUpperCase(), null);
			// 再次使用药物后是否出现同样反应
			newMap.put("adr_reuse_status".toUpperCase(), null);
			// 怀疑药品批准文号
			newMap.put("suspect_drug_approval_num".toUpperCase(), MapUtils.getString(map, "10"));
			// 怀疑药品编码
			newMap.put("suspect_drug_code".toUpperCase(), null);
			// 怀疑药品商品名
			newMap.put("suspect_drug_com_name".toUpperCase(), MapUtils.getString(map, "11"));
			// 怀疑药品通用名
			newMap.put("suspect_drug_gen_name".toUpperCase(), MapUtils.getString(map, "12"));
			// 怀疑药品生产厂商
			newMap.put("suspect_drug_manufac".toUpperCase(), MapUtils.getString(map, "14"));
			// 怀疑药品生产批号
			newMap.put("suspect_drug_batch_num".toUpperCase(), MapUtils.getString(map, "15"));
			// 怀疑药品用量
			newMap.put("suspect_drug_usage".toUpperCase(),
					MapUtils.getString(map, "18") + "日" + MapUtils.getString(map, "19") + "次,每次使用"
							+ MapUtils.getString(map, "16") + MapUtils.getString(map, "17"));
			// 怀疑药品给药途径
			newMap.put("suspect_drug_method".toUpperCase(), MapUtils.getString(map, "20"));
			// 怀疑药品开始日期
			newMap.put("suspect_drug_start".toUpperCase(), MapUtils.getString(map, "21"));
			// 怀疑药品结束日期
			newMap.put("suspect_drug_end".toUpperCase(), MapUtils.getString(map, "22"));
			// 怀疑药品用药原因
			newMap.put("suspect_drug_reason".toUpperCase(), MapUtils.getString(map, "23"));
			// 报告时间
			newMap.put("adr_report_time".toUpperCase(), MapUtils.getString(map, "28"));
			// 记录状态
			newMap.put("record_status".toUpperCase(), 1);


			newMapList.add(newMap);
		}

		return newMapList;
	}
	
	

	
	
	
	
	

}
